package zozopo.flow;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.OperatorOS;
import zozopo.background.operator.operations.OperatorTB;
import zozopo.background.operator.operations.OperatorlimitedTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class PreCountFlowcodeAction extends ActionSupport implements Action,SessionAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String limitedCode ="FLOW.COUNTCODE";
	
	//传入参数
	

	
	//传出参数
	private List<OperatorTB> opoeratorList;
	
	private Map<Object, Object> session;
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	
	
	public String execute(){
			

			
			String forward = SUCCESS;
			OperatorOS operatorOS = new OperatorOS();
			opoeratorList = operatorOS.select();
			
			operatorOS.releaseConnection();
			return forward;
	}

	public void validate() {
		//权限处理
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 
	
		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return ; 
		} 
		
		//用户权限
		Map<String,OperatorlimitedTB> operatorlimitedMap = (Map<String,OperatorlimitedTB>)session.get("operatorlimitedMap");
		
		if(operatorlimitedMap.get(limitedCode) == null){
			addFieldError("errormessage","没有统计工作量权限.");
			return;
		}
	}



	public static String getLimitedcode() {
		return limitedCode;
	}


	public List<OperatorTB> getOpoeratorList() {
		return opoeratorList;
	}


	public void setOpoeratorList(List<OperatorTB> opoeratorList) {
		this.opoeratorList = opoeratorList;
	}

}
